package com.arrogames.rgblabyrinth.game.rendering 
{
	import com.arrogames.lib.ash.rendering.RenderNode;
	import com.arrogames.lib.ash.rendering.RenderingSystem;
	import com.arrogames.tmx.CoordinateUtil;
	
	import flash.geom.Point;
	
	import net.pixelpracht.tmx.TMXOrientation;
	import net.pixelpracht.tmx.TmxMap;
	
	import starling.display.DisplayObjectContainer;
	
	/**
	 * ...
	 * @author Robin van den Bogaard
	 */
	public class TileRenderingSystem extends RenderingSystem {
		
		private var map:TmxMap;
		
		public function TileRenderingSystem(container:DisplayObjectContainer, map:TmxMap) {
			super(container);
			this.map = map;
		}
		
		override protected function updatePosition(node:RenderNode):void {
			if (map.orientation === TMXOrientation.ISOMETRIC) {
				var location:Point = CoordinateUtil.isometricToScreen(node.position.x, node.position.y, map.tileWidth, map.tileHeight);
				node.display.graphic.x = location.x + (map.width * map.tileWidth/2);
				node.display.graphic.y = location.y;
			} else {
				super.updatePosition(node);
			}
		}
		
	}

}